import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { loginData } from '../date/logindate';
import { registerData } from '../date/registerdate';
import { userInfoData } from '../date/userInfodata';

@Injectable({
  providedIn: 'root'
})
export class UserInfoService {

  constructor(private http:HttpClient) { }

  private userinfo:userInfoData={};

  Setuserinfo(a:userInfoData):void{
   this.userinfo=a;
   sessionStorage.setItem('user',JSON.stringify(this.userinfo))
  }

  Getuserinfo():userInfoData{
    if(this.userinfo!=null){
      this.userinfo=JSON.parse(sessionStorage.getItem('user')!);
    }
    return this.userinfo;
  }

  public useredit(useredit:userInfoData):Observable<any>{
    return this.http.post<any>('http://localhost:8080/useredit',useredit)
  }

}
